<template>
  <div>
    <h3>{{ names.name }}小朋友</h3>
    <table border="0" cellspacing="0" align="center">
      <tr>
        <td>{{ names.grade.name }}：</td>
        <td v-for="i in names.grade.grade">{{ i.name }}</td>
      </tr>
    </table>
    <button @click="sheng">点击升班</button>
  </div>
</template>

<script>
export default {
  name: "firends",
  data() {
    return {
      userid: localStorage.getItem('userid'),
      names: ''
    }
  },
  methods: {
    get_firend() {
      this.$axios.get('users/FirendAPI/?userid=' + this.userid)
        .then(res => {
          this.names = res.data.list
        })
    },
    sheng() {
      this.$axios.put('users/FirendAPI/?userid=' + this.userid)
        .then(res => {
          if (res.data.code == 200) {
            alert('升班成功')
            this.get_firend()
          } else {
            alert('不能再升了')
          }
        })
    }
  },
  mounted() {
    this.get_firend()
  }
}
</script>

<style scoped>

</style>
